package com.example.backend.repository;

import com.example.backend.domain.entity.Feedback;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

public interface FeedbackRepository extends JpaRepository<Feedback, Long> {
    Page<Feedback> findByTicket_Id(Long ticketId, Pageable pageable);
    
    // 统计方法
    long countByRating(Integer rating);
    long countByRatingGreaterThanEqual(Integer rating);
    
    @Query("SELECT AVG(f.rating) FROM Feedback f WHERE f.rating IS NOT NULL")
    Double getAverageRating();
}


